package com.ac.app.web.action.pick;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ac.app.dm.PickUrlListPar;
import com.ac.app.web.form.PkUrlListParForm;
import com.caac.core.web.action.BaseAction;
import com.caac.core.web.form.BaseForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright AgileCentury 2008</p>
 * <p>Company: AgileCentury </p>
 * @author <a href="mailto:ac@agilecentury.com">Agile</a>
 * @version 1.0
 */

public class EditPkUrlListParAction extends BaseAction {

    protected ActionForward doExecute(ActionMapping mapping,
                                      BaseForm form,
                                      HttpServletRequest request,
                                      HttpServletResponse response)
            throws Exception {
    	PkUrlListParForm myForm = (PkUrlListParForm) form;
    	List list = getBaseManager().getObjects(PickUrlListPar.class,"pick_Entry = '" + request.getParameter("pEntryId")+"'");
    	PickUrlListPar pulp = null;
    	if(list.size()>0)
    		pulp = (PickUrlListPar)list.get(0);
    	else
    	{
    		pulp = new PickUrlListPar();
    		pulp.setPickEntry(request.getParameter("pEntryId"));
    		this.getBaseManager().saveObject(pulp);
    	}
        myForm.setPickUrlListPar(pulp);
        return forward(mapping);
    }
}
